<template>
  <div class="my">
    <div class="header">
      购物车
    </div>
    <div class="my_header">
      <div class="header-top">
        <i class="iconfont icon-shezhi1" @click="shezhiall()"></i>
        <router-link tag="p" to="sales">我要卖货</router-link>
      </div>
      <div class="header-center">
        <div class="center-left">
          <div class="ChatHead"></div>
          <div class="name-phone">
            <span class="name" @click="toprofileshoping()">{{this.$store.state.userInfo.nickname}}</span>
            <p class="phone">{{this.$store.state.userInfo.phone | phoneHide}}</p>
          </div>
        </div>
        <i class="iconfont icon-right"></i>
      </div>
      <div class="order">
        <div class="order-top">
          <h5 class="my-order">我的订单</h5>
          <div class="all">
            <router-link to="orders" tag="span">查看全部</router-link>
            <i class="iconfont icon-right"></i>
          </div>
        </div>
        <ul class="order-list">
          <router-link to="orders" tag="li">
            <img src="../assets/3 (1).png" alt>
            <p>待付款</p>
          </router-link>
          <router-link to="orders" tag="li">
            <img src="../assets/3 (2).png" alt>
            <p>待发货</p>
          </router-link>
          <router-link to="orders" tag="li">
            <img src="../assets/3 (3).png" alt>
            <p>待收货</p>
          </router-link>
           <router-link to="orders" tag="li">
            <img src="../assets/3 (4).png" alt>
            <p>已完成</p>
           </router-link>
        </ul>
      </div>
    </div>
    <div class="coupon">
      <ul class="coupon-list">
        <li>
          <span>{{list.PENDING_PAYMENT}}</span>
          <p @click="jumthrss()">优惠券</p>
        </li>
        <li  @click="jumpone()">
          <span>{{list.COLLECTGOODCOUNT}}</span>
          <p>商品收藏</p>
        </li>
        <li  @click="jumptwo()" >
          <span>{{list.COLLECTDEALERCOUNT}}</span>
          <p>店铺收藏</p>
        </li>
        <router-link tag="li" to="/Supplier">
          <span>{{list.USERDEALERRELCOUNT}}</span>
          <p>我的供应商</p>
        </router-link>
      </ul>
    </div>
    <div class="logistics">
      <div class="logistics-list">
        <div class="logistics-left">
          <span>最新物流</span>
          <p>20:37:35</p>
        </div>
        <ul class="logistics-right">
          <li>
            <div class="logistics-right-left"></div>
            <div class="logistics-right-right">
              <div class="logistics-right-top">
                <span>待收货</span>
                <p>订单编号：887654433388888</p>
              </div>
              <p class="logistics-right-bottom">【运单1】你的运单已经打包完成,准备出库</p>
            </div>
          </li>
        </ul>
      </div>
      <div class="logistics-list">
        <div class="logistics-left">
          <span>最新物流</span>
          <p>20:37:35</p>
        </div>
        <ul class="logistics-right">
          <li>
            <div class="logistics-right-left"></div>
            <div class="logistics-right-right">
              <div class="logistics-right-top">
                <span>待收货</span>
                <p>订单编号：887654433388888</p>
              </div>
              <p class="logistics-right-bottom">【运单1】你的运单已经打包完成,准备出库</p>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <div class="browse">
      <img src="../assets/remen-left-icon@3x.png" alt>
      <span>最近浏览</span>
      <img src="../assets/remen-right-icon@3x.png" alt>
    </div>
    <ul class="browse-list">
      <li v-for="(item,index) in lis" :key="index">
        <img :src="item.mainPic||item.picsUrl|picsUrl" alt @click="Gotodetails(item)">
        <div class="text">
          <p @click="Gotodetails(item)">{{item.goodsName}}</p>
          <div class="browse-list-bo">
            <div @click="Gotodetails(item)">
              <div class="money">
                <i>￥</i>
                <span>{{item.orderPrice|addZero}}</span>
              </div>
              <p class="si" v-if="item.dealer">{{item.dealer.name}}</p>
            </div>
            <shoppingCar :goodsId="item.skuId"></shoppingCar>
          </div>
          
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
import shoppingCar from '../components/shoppingCar'
export default {
  components:{
    shoppingCar,
  },
  data() {
    return {
      list: "",
      lis:[],
      urlImg:[]
    };
  },
  methods: {
    toprofileshoping(){
       this.$router.push({path:'profileshoping'})
    },
    shezhiall(){
      this.$router.push({path:'shezhiall'})
    },
    jumthrss(){
      this.$router.push({path:"coupon"})
    },
    jumpone(){
      this.$router.push({path:"shopcollect"})
    },
    jumptwo(){
       this.$router.push({path:"shoptoshop"})
    },
    Gotodetails(item){
      let skuid=item.skuId
      this.$router.push({name:'details',query:{skuid:skuid}})
    },
    getAxios() {
      let headers;
      if (this.$store.state.token) {
        headers = {
          token: this.$store.state.token,
          userId: this.$store.state.userInfo.id
        };
      } else {
        headers = {};
      }
      this.$http
        .get("https://web-gateway.newbeescm.com/b2b-app-web/countOrder", {
          headers,
          params: {
            merchantId: this.$store.state.merchantInfo.merchantId,
            userId: this.$store.state.userInfo.id
          }
        })
        .then(res => {
          console.log(res);
          if (res.data.status.statusCode === 0) {
            this.list = res.data.result;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    getGoodsRecordByUserId() {
      this.$http
        .post(
          "https://web-gateway.newbeescm.com/b2b-app-web/getGoodsRecordByUserId",
          {
            dealerId: this.$store.state.merchantInfo.id,
            groupStoreId: this.$store.state.storeId.storeId,
            merchantId: this.$store.state.merchantInfo.merchantId,
            pageNum: 1,
            pageSize: 20,
            shopId: this.$store.state.storeId.storeId,
            stationId: this.$store.state.stationId,
            userId: this.$store.state.userInfo.id
          },
          {
            headers: {
              token: this.$store.state.token,
              userId: this.$store.state.userInfo.id
            }
          }
        )
        .then(res => {
          console.log(res);
          if (res.data.status.statusCode === 0) {
            this.lis=res.data.result
            this.urlImg=res.data.result[0].picsUrl.split(",")
            console.log(this.urlImg[0])
          }
        })
        .catch(err => {
          console.log(err);
        });
    }
  },
  filters: {
    phoneHide(val) {
      val = val.toString()
      if(val.length == 11) {
        return val.slice(0,3) + '****' + val.slice(7,11)
      }
      return val
    },
    picsUrl(val){
      if(val) {
        return val.split(',')[0]
      }else {
        return val
      }
    },
    addZero(value){
      if(isNaN(Number(value))){
          return value
      }
      return Number(value).toFixed(2)
}
  },
  created() {
    this.getAxios();
    this.getGoodsRecordByUserId();
  }
};
</script>
<style scoped lang="scss">
.my {
  background: #f8f8f8;
}
.header {
  height: 0.43rem;
  text-align: center;
  font-size: 0.18rem;
  color: #030303;
  line-height: 0.48rem;
  background: #ffffff;
  position: sticky;
  top: 0;
  left: 0;
  background: #fff;
  z-index: 99;
}
.my_header {
  height: 1.4rem;
  background-image: linear-gradient(90deg, #dd3333 3%, #f46839 100%);
  position: relative;
  .header-top {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.11rem;
    align-items: center;
    .icon-shezhi1 {
      color: #fff;
      font-size: 0.18rem;
    }
    p {
      width: 0.77rem;
      height: 0.24rem;
      border: 1px solid #fff;
      border-radius: 100px;
      color: #fff;
      font-size: 0.14rem;
      text-align: center;
      line-height: 0.24rem;
      margin: 0 0.14rem 0 0.24rem;
    }
  }
  .header-center {
    padding: 0 0.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .center-left {
      display: flex;
      align-items: center;
      .ChatHead {
        width: 0.6rem;
        height: 0.6rem;
        background: pink;
        border: 4px solid rgba(255, 255, 255, 0.6);
        border-radius: 50%;
      }
      .name-phone {
        margin-left: 0.15rem;
        color: #fff;
        .phone {
          margin-top: 0.1rem;
          font-size: 0.12rem;
        }
      }
    }
    .icon-right {
      color: #fff;
      font-size: 0.16rem;
    }
  }
}
.order {
  height: 1.29rem;
  background: #fff;
  padding: 0 0.1rem;
  position: absolute;
  top: 1.15rem;
  left: 0.1rem;
  right: 0.1rem;
  .order-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.13rem 0.14rem;
    position: relative;
    .my-order {
      font-size: 0.14rem;
      color: #333;
    }
    .all {
      span {
        font-size: 0.12rem;
        color: #666;
        margin-right: 0.08rem;
      }
      .icon-right {
        color: #ccc;
        font-size: 0.14rem;
      }
    }
  }
  .order-top::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: #eee;
    transform: scale(1, 0.5);
  }
  .order-list {
    padding: 0.19rem 0.26rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    li {
      text-align: center;
      // display: flex;
      // flex-wrap: wrap;
      img {
        width: 0.24rem;
        height: 0.24rem;
      }
      p {
        font-size: 0.13rem;
        color: #333;
        margin-top: 0.05rem;
      }
    }
  }
}
.coupon {
  margin: 1.15rem 0.1rem 0.1rem 0.1rem;
  background: #fff;
  .coupon-list {
    height: 0.8rem;
    padding: 0 0.35rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    li {
      text-align: center;
      span {
        font-size: 0.2rem;
        font-weight: bolder;
      }
      p {
        font-size: 0.12rem;
        color: #333;
      }
    }
  }
}
.logistics {
  background: #fff;
  // height: 1.31rem;
  margin: 0.1rem;
  padding: 0.1rem 0.13rem;
  .logistics-list {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .logistics-left {
    padding-top: 0.1rem;
    // margin-right: 0.13rem;
    font-size: 0.1rem;
    position: relative;
    span {
      color: #999;
    }
    p {
      margin-top: 0.08rem;
      color: #666;
    }
  }
  .logistics-left::after {
    content: "";
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    height: 1px;
    background: #eee;
    transform: scale(1, 0.5);
    // transform: rotateY(90deg);
  }
  .logistics-right {
    // margin-left: 0.14rem;
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
    li {
      display: flex;
      // list-style: disc;

      .logistics-right-left {
        width: 0.36rem;
        height: 0.36rem;
        background: aquamarine;
      }
      .logistics-right-right {
        margin-left: 0.1rem;
        .logistics-right-top {
          display: flex;
          justify-content: space-between;
          align-items: center;
          span {
            font-size: 0.12rem;
            color: #dd3333;
          }
          p {
            font-size: 0.1rem;
            color: #999;
          }
        }
        .logistics-right-bottom {
          font-size: 0.11rem;
          color: #666;
          line-height: 0.11rem;
          margin-top: 0.1rem;
          margin-left: -0.05rem;
        }
      }
    }
  }
}
.browse {
  text-align: center;
  padding-bottom: 0.1rem;
  img {
    width: 0.27rem;
    height: 0.16rem;
  }
  span {
    font-size: 0.14rem;
    color: #dd3333;
  }
}
.browse-list {
  background: #fff;
  li {
    padding: 0.13rem 0.14rem;
    display: flex;
    position: relative;
    // justify-content: space-between;
    img{
      width: 1rem;
      height: 1rem;
      min-width: 1rem;
      // background: pink;
    }
    .text {
      margin-left: 0.09rem;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      flex: 1;
      p {
        font-size: 0.14rem;
        color: #333;
      }
      .money {
        // margin-top: 0.35rem;
        i {
          font-size: 0.12rem;
          color: #dd3333;
        }
        span {
          font-size: 0.14rem;
          color: #dd3333;
          margin-left: 0.05rem;
        }
      }
      .si{
        font-size: 0.12rem;
        color: #999;
      }
    }
  }
  li::after{
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    height: 1px;
    background: #eee;
    width: 100%;
    transform: scale(1,0.5);
  }
  .browse-list-bo{
    display: flex;
    justify-content: space-between;
    align-items: center;
    .icon-gou_wu_che2{
      color: #dd3333;
      font-size: 0.16rem;
    }
  }
}
</style>

function newFunction() {
  return 'shoptoshop';
}
